import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import tech.bmatch.meituan.model.Merchant;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;

public class JsonTest2 {
    public static void main(String[] args) {
        ObjectMapper objectMapper = new ObjectMapper();
        List<Merchant> merchantList = null;
        try {
            merchantList = objectMapper.readValue(new File("./demo.json"),
                    new TypeReference<List<Merchant>>() {
                    });
        } catch (IOException e) {
            e.printStackTrace();
        }
        List<Merchant> merchantList1 = merchantList.stream().filter(m ->
                m.getName().indexOf("必胜客") >= 0).collect(Collectors.toList());
        for (Merchant merchant : merchantList1) {
            System.out.println(merchant.getName());
        }
    }
}
